#include "DXText.h"

DXText::DXText (void)
{
	TextBox.bottom = 200; TextBox.top = 0;
	TextBox.left = 0; TextBox.right = 1000;
}

DXText::DXText (LPDIRECT3DDEVICE9 DrawDevice, UINT TextSize, LPCTSTR FontName, DWORD TextColor)
{
	Device = DrawDevice;
	Size = TextSize;
	FaceName = FontName;
	Color = TextColor;
	TextBox.bottom = 200; TextBox.top = 0;
	TextBox.left = 0; TextBox.right = 1000;
	CreateFont();
}

DXText::~DXText (void)
{
}

void DXText::CreateFont (void)
{
	D3DXCreateFont(Device, Size, 0, FW_NORMAL, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
				   DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, FaceName, &Font);
}

void DXText::Draw (void)
{
	Font->DrawTextA(NULL, DisplayText, (int)strlen(DisplayText), &TextBox, DT_LEFT | DT_TOP, Color);
}

void DXText::SetTextSize (UINT TextSize)
{
	Size = TextSize;
	Font->Release();
	this->CreateFont();
}

void DXText::SetFont (LPCTSTR FontName)
{
	FaceName = FontName;
	Font->Release();
	this->CreateFont();
}

void DXText::SetColor (DWORD TextColor)
{
	Color = TextColor;
}

void DXText::SetTextLocation (LONG Left, LONG Top)
{
	TextBox.bottom = Top + 200;
	TextBox.left = Left;
	TextBox.right = Left + 1000;
	TextBox.top = Top;
}

void DXText::SetText (LPCSTR Text)
{
	DisplayText = Text;
}

LONG DXText::GetTextLeftLocation (void)
{
	return TextBox.left;
}

LONG DXText::GetTextTopLocation (void)
{
	return TextBox.top;
}